<!-- HTML header for doxygen 1.8.6-->
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/xhtml;charset=UTF-8"/>
<meta http-equiv="X-UA-Compatible" content="IE=9"/>
<meta name="generator" content="Doxygen 1.8.13"/>
<title>OpenCV: cv::RNG Class Reference</title>
<link href="../../opencv.ico" rel="shortcut icon" type="image/x-icon" />
<link href="../../tabs.css" rel="stylesheet" type="text/css"/>
<script type="text/javascript" src="../../jquery.js"></script>
<script type="text/javascript" src="../../dynsections.js"></script>
<script type="text/javascript" src="../../tutorial-utils.js"></script>
<link href="../../search/search.css" rel="stylesheet" type="text/css"/>
<script type="text/javascript" src="../../search/searchdata.js"></script>
<script type="text/javascript" src="../../search/search.js"></script>
<script type="text/x-mathjax-config">
  MathJax.Hub.Config({
    extensions: ["tex2jax.js", "TeX/AMSmath.js", "TeX/AMSsymbols.js"],
    jax: ["input/TeX","output/HTML-CSS"],
});
//<![CDATA[
MathJax.Hub.Config(
{
  TeX: {
      Macros: {
          matTT: [ "\\[ \\left|\\begin{array}{ccc} #1 & #2 & #3\\\\ #4 & #5 & #6\\\\ #7 & #8 & #9 \\end{array}\\right| \\]", 9],
          fork: ["\\left\\{ \\begin{array}{l l} #1 & \\mbox{#2}\\\\ #3 & \\mbox{#4}\\\\ \\end{array} \\right.", 4],
          forkthree: ["\\left\\{ \\begin{array}{l l} #1 & \\mbox{#2}\\\\ #3 & \\mbox{#4}\\\\ #5 & \\mbox{#6}\\\\ \\end{array} \\right.", 6],
          forkfour: ["\\left\\{ \\begin{array}{l l} #1 & \\mbox{#2}\\\\ #3 & \\mbox{#4}\\\\ #5 & \\mbox{#6}\\\\ #7 & \\mbox{#8}\\\\ \\end{array} \\right.", 8],
          vecthree: ["\\begin{bmatrix} #1\\\\ #2\\\\ #3 \\end{bmatrix}", 3],
          vecthreethree: ["\\begin{bmatrix} #1 & #2 & #3\\\\ #4 & #5 & #6\\\\ #7 & #8 & #9 \\end{bmatrix}", 9],
          cameramatrix: ["#1 = \\begin{bmatrix} f_x & 0 & c_x\\\\ 0 & f_y & c_y\\\\ 0 & 0 & 1 \\end{bmatrix}", 1],
          distcoeffs: ["(k_1, k_2, p_1, p_2[, k_3[, k_4, k_5, k_6 [, s_1, s_2, s_3, s_4[, \\tau_x, \\tau_y]]]]) \\text{ of 4, 5, 8, 12 or 14 elements}"],
          distcoeffsfisheye: ["(k_1, k_2, k_3, k_4)"],
          hdotsfor: ["\\dots", 1],
          mathbbm: ["\\mathbb{#1}", 1],
          bordermatrix: ["\\matrix{#1}", 1]
      }
  }
}
);
//]]>
</script><script type="text/javascript" src="https://cdnjs.cloudflare.com/ajax/libs/mathjax/2.7.0/MathJax.js"></script>
<link href="../../doxygen.css" rel="stylesheet" type="text/css" />
<link href="../../stylesheet.css" rel="stylesheet" type="text/css"/>
</head>
<body>
<div id="top"><!-- do not remove this div, it is closed by doxygen! -->
<div id="titlearea">
<!--#include virtual="/google-search.html"-->
<table cellspacing="0" cellpadding="0">
 <tbody>
 <tr style="height: 56px;">
  <td id="projectlogo"><img alt="Logo" src="../../opencv-logo-small.png"/></td>
  <td style="padding-left: 0.5em;">
   <div id="projectname">OpenCV
   &#160;<span id="projectnumber">4.5.2</span>
   </div>
   <div id="projectbrief">Open Source Computer Vision</div>
  </td>
 </tr>
 </tbody>
</table>
</div>
<!-- end header part -->
<!-- Generated by Doxygen 1.8.13 -->
<script type="text/javascript">
var searchBox = new SearchBox("searchBox", "../../search",false,'Search');
</script>
<script type="text/javascript" src="../../menudata.js"></script>
<script type="text/javascript" src="../../menu.js"></script>
<script type="text/javascript">
$(function() {
  initMenu('../../',true,false,'search.php','Search');
  $(document).ready(function() { init_search(); });
});
</script>
<div id="main-nav"></div>
<!-- window showing the filter options -->
<div id="MSearchSelectWindow"
     onmouseover="return searchBox.OnSearchSelectShow()"
     onmouseout="return searchBox.OnSearchSelectHide()"
     onkeydown="return searchBox.OnSearchSelectKey(event)">
</div>

<!-- iframe showing the search results (closed by default) -->
<div id="MSearchResultsWindow">
<iframe src="javascript:void(0)" frameborder="0" 
        name="MSearchResults" id="MSearchResults">
</iframe>
</div>

<div id="nav-path" class="navpath">
  <ul>
<li class="navelem"><a class="el" href="../../d2/d75/namespacecv.html">cv</a></li><li class="navelem"><a class="el" href="../../d1/dd6/classcv_1_1RNG.html">RNG</a></li>  </ul>
</div>
</div><!-- top -->
<div class="header">
  <div class="summary">
<a href="#pub-types">Public Types</a> &#124;
<a href="#pub-methods">Public Member Functions</a> &#124;
<a href="#pub-attribs">Public Attributes</a> &#124;
<a href="../../de/dcc/classcv_1_1RNG-members.html">List of all members</a>  </div>
  <div class="headertitle">
<div class="title">cv::RNG Class Reference<div class="ingroups"><a class="el" href="../../d0/de1/group__core.html">Core functionality</a> &raquo; <a class="el" href="../../d2/de8/group__core__array.html">Operations on arrays</a></div></div>  </div>
</div><!--header-->
<div class="contents">

<p>Random Number Generator.  
 <a href="../../d1/dd6/classcv_1_1RNG.html#details">More...</a></p>

<p><code>#include &lt;opencv2/core.hpp&gt;</code></p>
<table class="memberdecls">
<tr class="heading"><td colspan="2"><h2 class="groupheader"><a name="pub-types"></a>
Public Types</h2></td></tr>
<tr class="memitem:aa1ca9b6b8a00b2d04288f9f5b5e68238"><td class="memItemLeft" align="right" valign="top">enum &#160;</td><td class="memItemRight" valign="bottom">{ <br />
&#160;&#160;<a class="el" href="../../d1/dd6/classcv_1_1RNG.html#aa1ca9b6b8a00b2d04288f9f5b5e68238af6797281458bec27565ee730ea228d4a">UNIFORM</a> = 0, 
<br />
&#160;&#160;<a class="el" href="../../d1/dd6/classcv_1_1RNG.html#aa1ca9b6b8a00b2d04288f9f5b5e68238a85da6d7bc413e10a648f638151129a91">NORMAL</a> = 1
<br />
 }</td></tr>
<tr class="separator:aa1ca9b6b8a00b2d04288f9f5b5e68238"><td class="memSeparator" colspan="2">&#160;</td></tr>
</table><table class="memberdecls">
<tr class="heading"><td colspan="2"><h2 class="groupheader"><a name="pub-methods"></a>
Public Member Functions</h2></td></tr>
<tr class="memitem:a06c28035e383bc9eff22e1fad619ddf6"><td class="memItemLeft" align="right" valign="top">&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="../../d1/dd6/classcv_1_1RNG.html#a06c28035e383bc9eff22e1fad619ddf6">RNG</a> ()</td></tr>
<tr class="memdesc:a06c28035e383bc9eff22e1fad619ddf6"><td class="mdescLeft">&#160;</td><td class="mdescRight">constructor  <a href="#a06c28035e383bc9eff22e1fad619ddf6">More...</a><br /></td></tr>
<tr class="separator:a06c28035e383bc9eff22e1fad619ddf6"><td class="memSeparator" colspan="2">&#160;</td></tr>
<tr class="memitem:a2d2f54a5a1145e5b9f645b8983c6ae75"><td class="memItemLeft" align="right" valign="top">&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="../../d1/dd6/classcv_1_1RNG.html#a2d2f54a5a1145e5b9f645b8983c6ae75">RNG</a> (<a class="el" href="../../d1/d1b/group__core__hal__interface.html#gabc0f5bc07737e498f287334775dff2b6">uint64</a> <a class="el" href="../../d1/dd6/classcv_1_1RNG.html#a993bd2e6a5a9b8f3b37ba6049b523136">state</a>)</td></tr>
<tr class="separator:a2d2f54a5a1145e5b9f645b8983c6ae75"><td class="memSeparator" colspan="2">&#160;</td></tr>
<tr class="memitem:ad26f2b09d9868cf108e84c9814aa682d"><td class="memItemLeft" align="right" valign="top">void&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="../../d1/dd6/classcv_1_1RNG.html#ad26f2b09d9868cf108e84c9814aa682d">fill</a> (<a class="el" href="../../dc/d84/group__core__basic.html#gaf77c9a14ef956c50c1efd4547f444e63">InputOutputArray</a> mat, int distType, <a class="el" href="../../dc/d84/group__core__basic.html#ga353a9de602fe76c709e12074a6f362ba">InputArray</a> a, <a class="el" href="../../dc/d84/group__core__basic.html#ga353a9de602fe76c709e12074a6f362ba">InputArray</a> b, bool saturateRange=false)</td></tr>
<tr class="memdesc:ad26f2b09d9868cf108e84c9814aa682d"><td class="mdescLeft">&#160;</td><td class="mdescRight">Fills arrays with random numbers.  <a href="#ad26f2b09d9868cf108e84c9814aa682d">More...</a><br /></td></tr>
<tr class="separator:ad26f2b09d9868cf108e84c9814aa682d"><td class="memSeparator" colspan="2">&#160;</td></tr>
<tr class="memitem:a8df8ce4dc7d15916cee743e5a884639d"><td class="memItemLeft" align="right" valign="top">double&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="../../d1/dd6/classcv_1_1RNG.html#a8df8ce4dc7d15916cee743e5a884639d">gaussian</a> (double sigma)</td></tr>
<tr class="memdesc:a8df8ce4dc7d15916cee743e5a884639d"><td class="mdescLeft">&#160;</td><td class="mdescRight">Returns the next random number sampled from the Gaussian distribution.  <a href="#a8df8ce4dc7d15916cee743e5a884639d">More...</a><br /></td></tr>
<tr class="separator:a8df8ce4dc7d15916cee743e5a884639d"><td class="memSeparator" colspan="2">&#160;</td></tr>
<tr class="memitem:ad8d035897a5e31e7fc3e1e6c378c32f5"><td class="memItemLeft" align="right" valign="top">unsigned&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="../../d1/dd6/classcv_1_1RNG.html#ad8d035897a5e31e7fc3e1e6c378c32f5">next</a> ()</td></tr>
<tr class="separator:ad8d035897a5e31e7fc3e1e6c378c32f5"><td class="memSeparator" colspan="2">&#160;</td></tr>
<tr class="memitem:a5e3c36ffa74d7786313037c838c429eb"><td class="memItemLeft" align="right" valign="top">&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="../../d1/dd6/classcv_1_1RNG.html#a5e3c36ffa74d7786313037c838c429eb">operator double</a> ()</td></tr>
<tr class="separator:a5e3c36ffa74d7786313037c838c429eb"><td class="memSeparator" colspan="2">&#160;</td></tr>
<tr class="memitem:a6c542e1c042c18b82ac447747445de9b"><td class="memItemLeft" align="right" valign="top">&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="../../d1/dd6/classcv_1_1RNG.html#a6c542e1c042c18b82ac447747445de9b">operator float</a> ()</td></tr>
<tr class="separator:a6c542e1c042c18b82ac447747445de9b"><td class="memSeparator" colspan="2">&#160;</td></tr>
<tr class="memitem:a5f01fd132f75a87cc2ed153bf9907240"><td class="memItemLeft" align="right" valign="top">&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="../../d1/dd6/classcv_1_1RNG.html#a5f01fd132f75a87cc2ed153bf9907240">operator schar</a> ()</td></tr>
<tr class="separator:a5f01fd132f75a87cc2ed153bf9907240"><td class="memSeparator" colspan="2">&#160;</td></tr>
<tr class="memitem:ac6584b40ce8f99260210bcac615bd1ed"><td class="memItemLeft" align="right" valign="top">&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="../../d1/dd6/classcv_1_1RNG.html#ac6584b40ce8f99260210bcac615bd1ed">operator short</a> ()</td></tr>
<tr class="separator:ac6584b40ce8f99260210bcac615bd1ed"><td class="memSeparator" colspan="2">&#160;</td></tr>
<tr class="memitem:a8b1a6322d1cac24cd929aecad1041f22"><td class="memItemLeft" align="right" valign="top">&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="../../d1/dd6/classcv_1_1RNG.html#a8b1a6322d1cac24cd929aecad1041f22">operator uchar</a> ()</td></tr>
<tr class="separator:a8b1a6322d1cac24cd929aecad1041f22"><td class="memSeparator" colspan="2">&#160;</td></tr>
<tr class="memitem:a8419e63b25666f77d2d388aaae8122ba"><td class="memItemLeft" align="right" valign="top">&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="../../d1/dd6/classcv_1_1RNG.html#a8419e63b25666f77d2d388aaae8122ba">operator unsigned</a> ()</td></tr>
<tr class="separator:a8419e63b25666f77d2d388aaae8122ba"><td class="memSeparator" colspan="2">&#160;</td></tr>
<tr class="memitem:a51e4c416b3ace4840774cceaedcc4b9a"><td class="memItemLeft" align="right" valign="top">&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="../../d1/dd6/classcv_1_1RNG.html#a51e4c416b3ace4840774cceaedcc4b9a">operator ushort</a> ()</td></tr>
<tr class="separator:a51e4c416b3ace4840774cceaedcc4b9a"><td class="memSeparator" colspan="2">&#160;</td></tr>
<tr class="memitem:a16ca31c8e2ec0990df323b442ab09e4f"><td class="memItemLeft" align="right" valign="top">unsigned&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="../../d1/dd6/classcv_1_1RNG.html#a16ca31c8e2ec0990df323b442ab09e4f">operator()</a> ()</td></tr>
<tr class="memdesc:a16ca31c8e2ec0990df323b442ab09e4f"><td class="mdescLeft">&#160;</td><td class="mdescRight">returns a random integer sampled uniformly from [0, N).  <a href="#a16ca31c8e2ec0990df323b442ab09e4f">More...</a><br /></td></tr>
<tr class="separator:a16ca31c8e2ec0990df323b442ab09e4f"><td class="memSeparator" colspan="2">&#160;</td></tr>
<tr class="memitem:ac0112dc300696b1fc7998d37f15dd733"><td class="memItemLeft" align="right" valign="top">unsigned&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="../../d1/dd6/classcv_1_1RNG.html#ac0112dc300696b1fc7998d37f15dd733">operator()</a> (unsigned N)</td></tr>
<tr class="separator:ac0112dc300696b1fc7998d37f15dd733"><td class="memSeparator" colspan="2">&#160;</td></tr>
<tr class="memitem:a6c4889ee703a2b667df1fa298ffa312f"><td class="memItemLeft" align="right" valign="top">bool&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="../../d1/dd6/classcv_1_1RNG.html#a6c4889ee703a2b667df1fa298ffa312f">operator==</a> (const <a class="el" href="../../d1/dd6/classcv_1_1RNG.html">RNG</a> &amp;other) const</td></tr>
<tr class="separator:a6c4889ee703a2b667df1fa298ffa312f"><td class="memSeparator" colspan="2">&#160;</td></tr>
<tr class="memitem:acde197860cea91e5aa896be8719457ae"><td class="memItemLeft" align="right" valign="top">int&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="../../d1/dd6/classcv_1_1RNG.html#acde197860cea91e5aa896be8719457ae">uniform</a> (int a, int b)</td></tr>
<tr class="memdesc:acde197860cea91e5aa896be8719457ae"><td class="mdescLeft">&#160;</td><td class="mdescRight">returns uniformly distributed integer random number from [a,b) range  <a href="#acde197860cea91e5aa896be8719457ae">More...</a><br /></td></tr>
<tr class="separator:acde197860cea91e5aa896be8719457ae"><td class="memSeparator" colspan="2">&#160;</td></tr>
<tr class="memitem:a47acb9cf49f56ae6b86ab08c51f0f7d3"><td class="memItemLeft" align="right" valign="top">float&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="../../d1/dd6/classcv_1_1RNG.html#a47acb9cf49f56ae6b86ab08c51f0f7d3">uniform</a> (float a, float b)</td></tr>
<tr class="separator:a47acb9cf49f56ae6b86ab08c51f0f7d3"><td class="memSeparator" colspan="2">&#160;</td></tr>
<tr class="memitem:a8325cc562269b47bcac2343639b6fafc"><td class="memItemLeft" align="right" valign="top">double&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="../../d1/dd6/classcv_1_1RNG.html#a8325cc562269b47bcac2343639b6fafc">uniform</a> (double a, double b)</td></tr>
<tr class="separator:a8325cc562269b47bcac2343639b6fafc"><td class="memSeparator" colspan="2">&#160;</td></tr>
</table><table class="memberdecls">
<tr class="heading"><td colspan="2"><h2 class="groupheader"><a name="pub-attribs"></a>
Public Attributes</h2></td></tr>
<tr class="memitem:a993bd2e6a5a9b8f3b37ba6049b523136"><td class="memItemLeft" align="right" valign="top"><a class="el" href="../../d1/d1b/group__core__hal__interface.html#gabc0f5bc07737e498f287334775dff2b6">uint64</a>&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="../../d1/dd6/classcv_1_1RNG.html#a993bd2e6a5a9b8f3b37ba6049b523136">state</a></td></tr>
<tr class="separator:a993bd2e6a5a9b8f3b37ba6049b523136"><td class="memSeparator" colspan="2">&#160;</td></tr>
</table>
<a name="details" id="details"></a><h2 class="groupheader">Detailed Description</h2>
<div class="textblock"><p>Random Number Generator. </p>
<p>Random number generator. It encapsulates the state (currently, a 64-bit integer) and has methods to return scalar random values and to fill arrays with random values. Currently it supports uniform and Gaussian (normal) distributions. The generator uses Multiply-With-Carry algorithm, introduced by G. Marsaglia ( <a href="http://en.wikipedia.org/wiki/Multiply-with-carry">http://en.wikipedia.org/wiki/Multiply-with-carry</a> ). Gaussian-distribution random numbers are generated using the Ziggurat algorithm ( <a href="http://en.wikipedia.org/wiki/Ziggurat_algorithm">http://en.wikipedia.org/wiki/Ziggurat_algorithm</a> ), introduced by G. Marsaglia and W. W. Tsang. </p>
<dl><dt><b>Examples: </b></dt><dd><a class="el" href="../../d5/d04/samples_2cpp_2convexhull_8cpp-example.html#_a4">samples/cpp/convexhull.cpp</a>, <a class="el" href="../../d2/dcf/samples_2cpp_2falsecolor_8cpp-example.html#_a14">samples/cpp/falsecolor.cpp</a>, <a class="el" href="../../dd/d93/samples_2cpp_2image_alignment_8cpp-example.html#_a29">samples/cpp/image_alignment.cpp</a>, <a class="el" href="../../d9/dde/samples_2cpp_2kmeans_8cpp-example.html#_a4">samples/cpp/kmeans.cpp</a>, <a class="el" href="../../df/dee/samples_2cpp_2minarea_8cpp-example.html#_a3">samples/cpp/minarea.cpp</a>, <a class="el" href="../../de/d06/samples_2cpp_2tutorial_code_2ImgProc_2basic_drawing_2Drawing_2_8cpp-example.html#_a1">samples/cpp/tutorial_code/ImgProc/basic_drawing/Drawing_2.cpp</a>, and <a class="el" href="../../d6/d14/samples_2cpp_2tutorial_code_2ImgTrans_2copyMakeBorder_demo_8cpp-example.html#_a2">samples/cpp/tutorial_code/ImgTrans/copyMakeBorder_demo.cpp</a>.</dd>
</dl></div><h2 class="groupheader">Member Enumeration Documentation</h2>
<a id="aa1ca9b6b8a00b2d04288f9f5b5e68238"></a>
<h2 class="memtitle"><span class="permalink"><a href="#aa1ca9b6b8a00b2d04288f9f5b5e68238">&#9670;&nbsp;</a></span>anonymous enum</h2>

<div class="memitem">
<div class="memproto">
      <table class="memname">
        <tr>
          <td class="memname">anonymous enum</td>
        </tr>
      </table>
</div><div class="memdoc">
<table class="fieldtable">
<tr><th colspan="2">Enumerator</th></tr><tr><td class="fieldname"><a id="aa1ca9b6b8a00b2d04288f9f5b5e68238af6797281458bec27565ee730ea228d4a"></a>UNIFORM&#160;</td><td class="fielddoc"></td></tr>
<tr><td class="fieldname"><a id="aa1ca9b6b8a00b2d04288f9f5b5e68238a85da6d7bc413e10a648f638151129a91"></a>NORMAL&#160;</td><td class="fielddoc"></td></tr>
</table>

</div>
</div>
<h2 class="groupheader">Constructor &amp; Destructor Documentation</h2>
<a id="a06c28035e383bc9eff22e1fad619ddf6"></a>
<h2 class="memtitle"><span class="permalink"><a href="#a06c28035e383bc9eff22e1fad619ddf6">&#9670;&nbsp;</a></span>RNG() <span class="overload">[1/2]</span></h2>

<div class="memitem">
<div class="memproto">
      <table class="memname">
        <tr>
          <td class="memname">cv::RNG::RNG </td>
          <td>(</td>
          <td class="paramname"></td><td>)</td>
          <td></td>
        </tr>
      </table>
</div><div class="memdoc">

<p>constructor </p>
<p>These are the <a class="el" href="../../d1/dd6/classcv_1_1RNG.html" title="Random Number Generator. ">RNG</a> constructors. The first form sets the state to some pre-defined value, equal to 2**32-1 in the current implementation. The second form sets the state to the specified value. If you passed state=0 , the constructor uses the above default value instead to avoid the singular random number sequence, consisting of all zeros. </p>

</div>
</div>
<a id="a2d2f54a5a1145e5b9f645b8983c6ae75"></a>
<h2 class="memtitle"><span class="permalink"><a href="#a2d2f54a5a1145e5b9f645b8983c6ae75">&#9670;&nbsp;</a></span>RNG() <span class="overload">[2/2]</span></h2>

<div class="memitem">
<div class="memproto">
      <table class="memname">
        <tr>
          <td class="memname">cv::RNG::RNG </td>
          <td>(</td>
          <td class="paramtype"><a class="el" href="../../d1/d1b/group__core__hal__interface.html#gabc0f5bc07737e498f287334775dff2b6">uint64</a>&#160;</td>
          <td class="paramname"><em>state</em></td><td>)</td>
          <td></td>
        </tr>
      </table>
</div><div class="memdoc">
<p>This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts. </p><dl class="params"><dt>Parameters</dt><dd>
  <table class="params">
    <tr><td class="paramname">state</td><td>64-bit value used to initialize the <a class="el" href="../../d1/dd6/classcv_1_1RNG.html" title="Random Number Generator. ">RNG</a>. </td></tr>
  </table>
  </dd>
</dl>

</div>
</div>
<h2 class="groupheader">Member Function Documentation</h2>
<a id="ad26f2b09d9868cf108e84c9814aa682d"></a>
<h2 class="memtitle"><span class="permalink"><a href="#ad26f2b09d9868cf108e84c9814aa682d">&#9670;&nbsp;</a></span>fill()</h2>

<div class="memitem">
<div class="memproto">
      <table class="memname">
        <tr>
          <td class="memname">void cv::RNG::fill </td>
          <td>(</td>
          <td class="paramtype"><a class="el" href="../../dc/d84/group__core__basic.html#gaf77c9a14ef956c50c1efd4547f444e63">InputOutputArray</a>&#160;</td>
          <td class="paramname"><em>mat</em>, </td>
        </tr>
        <tr>
          <td class="paramkey"></td>
          <td></td>
          <td class="paramtype">int&#160;</td>
          <td class="paramname"><em>distType</em>, </td>
        </tr>
        <tr>
          <td class="paramkey"></td>
          <td></td>
          <td class="paramtype"><a class="el" href="../../dc/d84/group__core__basic.html#ga353a9de602fe76c709e12074a6f362ba">InputArray</a>&#160;</td>
          <td class="paramname"><em>a</em>, </td>
        </tr>
        <tr>
          <td class="paramkey"></td>
          <td></td>
          <td class="paramtype"><a class="el" href="../../dc/d84/group__core__basic.html#ga353a9de602fe76c709e12074a6f362ba">InputArray</a>&#160;</td>
          <td class="paramname"><em>b</em>, </td>
        </tr>
        <tr>
          <td class="paramkey"></td>
          <td></td>
          <td class="paramtype">bool&#160;</td>
          <td class="paramname"><em>saturateRange</em> = <code>false</code>&#160;</td>
        </tr>
        <tr>
          <td></td>
          <td>)</td>
          <td></td><td></td>
        </tr>
      </table>
</div><div class="memdoc">

<p>Fills arrays with random numbers. </p>
<dl class="params"><dt>Parameters</dt><dd>
  <table class="params">
    <tr><td class="paramname">mat</td><td>2D or N-dimensional matrix; currently matrices with more than 4 channels are not supported by the methods, use <a class="el" href="../../d3/d63/classcv_1_1Mat.html#a4eb96e3251417fa88b78e2abd6cfd7d8" title="Changes the shape and/or the number of channels of a 2D matrix without copying the data...">Mat::reshape</a> as a possible workaround. </td></tr>
    <tr><td class="paramname">distType</td><td>distribution type, <a class="el" href="../../d1/dd6/classcv_1_1RNG.html#aa1ca9b6b8a00b2d04288f9f5b5e68238af6797281458bec27565ee730ea228d4a">RNG::UNIFORM</a> or <a class="el" href="../../d1/dd6/classcv_1_1RNG.html#aa1ca9b6b8a00b2d04288f9f5b5e68238a85da6d7bc413e10a648f638151129a91">RNG::NORMAL</a>. </td></tr>
    <tr><td class="paramname">a</td><td>first distribution parameter; in case of the uniform distribution, this is an inclusive lower boundary, in case of the normal distribution, this is a mean value. </td></tr>
    <tr><td class="paramname">b</td><td>second distribution parameter; in case of the uniform distribution, this is a non-inclusive upper boundary, in case of the normal distribution, this is a standard deviation (diagonal of the standard deviation matrix or the full standard deviation matrix). </td></tr>
    <tr><td class="paramname">saturateRange</td><td>pre-saturation flag; for uniform distribution only; if true, the method will first convert a and b to the acceptable value range (according to the mat datatype) and then will generate uniformly distributed random numbers within the range [saturate(a), saturate(b)), if saturateRange=false, the method will generate uniformly distributed random numbers in the original range [a, b) and then will saturate them, it means, for example, that <code><a class="el" href="../../d2/de8/group__core__array.html#ga75843061d150ad6564b5447e38e57722" title="Returns the default random number generator. ">theRNG()</a>.fill(mat_8u, <a class="el" href="../../d1/dd6/classcv_1_1RNG.html#aa1ca9b6b8a00b2d04288f9f5b5e68238af6797281458bec27565ee730ea228d4a">RNG::UNIFORM</a>, -DBL_MAX, DBL_MAX)</code> will likely produce array mostly filled with 0's and 255's, since the range (0, 255) is significantly smaller than [-DBL_MAX, DBL_MAX).</td></tr>
  </table>
  </dd>
</dl>
<p>Each of the methods fills the matrix with the random values from the specified distribution. As the new numbers are generated, the <a class="el" href="../../d1/dd6/classcv_1_1RNG.html" title="Random Number Generator. ">RNG</a> state is updated accordingly. In case of multiple-channel images, every channel is filled independently, which means that <a class="el" href="../../d1/dd6/classcv_1_1RNG.html" title="Random Number Generator. ">RNG</a> cannot generate samples from the multi-dimensional Gaussian distribution with non-diagonal covariance matrix directly. To do that, the method generates samples from multi-dimensional standard Gaussian distribution with zero mean and identity covariation matrix, and then transforms them using transform to get samples from the specified Gaussian distribution. </p>
<dl><dt><b>Examples: </b></dt><dd><a class="el" href="../../d9/dde/samples_2cpp_2kmeans_8cpp-example.html#a14">samples/cpp/kmeans.cpp</a>.</dd>
</dl>
</div>
</div>
<a id="a8df8ce4dc7d15916cee743e5a884639d"></a>
<h2 class="memtitle"><span class="permalink"><a href="#a8df8ce4dc7d15916cee743e5a884639d">&#9670;&nbsp;</a></span>gaussian()</h2>

<div class="memitem">
<div class="memproto">
      <table class="memname">
        <tr>
          <td class="memname">double cv::RNG::gaussian </td>
          <td>(</td>
          <td class="paramtype">double&#160;</td>
          <td class="paramname"><em>sigma</em></td><td>)</td>
          <td></td>
        </tr>
      </table>
</div><div class="memdoc">

<p>Returns the next random number sampled from the Gaussian distribution. </p>
<dl class="params"><dt>Parameters</dt><dd>
  <table class="params">
    <tr><td class="paramname">sigma</td><td>standard deviation of the distribution.</td></tr>
  </table>
  </dd>
</dl>
<p>The method transforms the state using the MWC algorithm and returns the next random number from the Gaussian distribution N(0,sigma) . That is, the mean value of the returned random numbers is zero and the standard deviation is the specified sigma . </p>

</div>
</div>
<a id="ad8d035897a5e31e7fc3e1e6c378c32f5"></a>
<h2 class="memtitle"><span class="permalink"><a href="#ad8d035897a5e31e7fc3e1e6c378c32f5">&#9670;&nbsp;</a></span>next()</h2>

<div class="memitem">
<div class="memproto">
      <table class="memname">
        <tr>
          <td class="memname">unsigned cv::RNG::next </td>
          <td>(</td>
          <td class="paramname"></td><td>)</td>
          <td></td>
        </tr>
      </table>
</div><div class="memdoc">
<p>The method updates the state using the MWC algorithm and returns the next 32-bit random number. </p>

</div>
</div>
<a id="a5e3c36ffa74d7786313037c838c429eb"></a>
<h2 class="memtitle"><span class="permalink"><a href="#a5e3c36ffa74d7786313037c838c429eb">&#9670;&nbsp;</a></span>operator double()</h2>

<div class="memitem">
<div class="memproto">
      <table class="memname">
        <tr>
          <td class="memname">cv::RNG::operator double </td>
          <td>(</td>
          <td class="paramname"></td><td>)</td>
          <td></td>
        </tr>
      </table>
</div><div class="memdoc">
<p>This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts. </p>

</div>
</div>
<a id="a6c542e1c042c18b82ac447747445de9b"></a>
<h2 class="memtitle"><span class="permalink"><a href="#a6c542e1c042c18b82ac447747445de9b">&#9670;&nbsp;</a></span>operator float()</h2>

<div class="memitem">
<div class="memproto">
      <table class="memname">
        <tr>
          <td class="memname">cv::RNG::operator float </td>
          <td>(</td>
          <td class="paramname"></td><td>)</td>
          <td></td>
        </tr>
      </table>
</div><div class="memdoc">
<p>This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts. </p>

</div>
</div>
<a id="a5f01fd132f75a87cc2ed153bf9907240"></a>
<h2 class="memtitle"><span class="permalink"><a href="#a5f01fd132f75a87cc2ed153bf9907240">&#9670;&nbsp;</a></span>operator schar()</h2>

<div class="memitem">
<div class="memproto">
      <table class="memname">
        <tr>
          <td class="memname">cv::RNG::operator <a class="el" href="../../d1/d1b/group__core__hal__interface.html#ga0fd9ce9d735064461bebfe6037026093">schar</a> </td>
          <td>(</td>
          <td class="paramname"></td><td>)</td>
          <td></td>
        </tr>
      </table>
</div><div class="memdoc">
<p>This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts. </p>

</div>
</div>
<a id="ac6584b40ce8f99260210bcac615bd1ed"></a>
<h2 class="memtitle"><span class="permalink"><a href="#ac6584b40ce8f99260210bcac615bd1ed">&#9670;&nbsp;</a></span>operator short()</h2>

<div class="memitem">
<div class="memproto">
      <table class="memname">
        <tr>
          <td class="memname">cv::RNG::operator short </td>
          <td>(</td>
          <td class="paramname"></td><td>)</td>
          <td></td>
        </tr>
      </table>
</div><div class="memdoc">
<p>This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts. </p>

</div>
</div>
<a id="a8b1a6322d1cac24cd929aecad1041f22"></a>
<h2 class="memtitle"><span class="permalink"><a href="#a8b1a6322d1cac24cd929aecad1041f22">&#9670;&nbsp;</a></span>operator uchar()</h2>

<div class="memitem">
<div class="memproto">
      <table class="memname">
        <tr>
          <td class="memname">cv::RNG::operator <a class="el" href="../../d1/d1b/group__core__hal__interface.html#ga65f85814a8290f9797005d3b28e7e5fc">uchar</a> </td>
          <td>(</td>
          <td class="paramname"></td><td>)</td>
          <td></td>
        </tr>
      </table>
</div><div class="memdoc">
<p>Each of the methods updates the state using the MWC algorithm and returns the next random number of the specified type. In case of integer types, the returned number is from the available value range for the specified type. In case of floating-point types, the returned value is from [0,1) range. </p>

</div>
</div>
<a id="a8419e63b25666f77d2d388aaae8122ba"></a>
<h2 class="memtitle"><span class="permalink"><a href="#a8419e63b25666f77d2d388aaae8122ba">&#9670;&nbsp;</a></span>operator unsigned()</h2>

<div class="memitem">
<div class="memproto">
      <table class="memname">
        <tr>
          <td class="memname">cv::RNG::operator unsigned </td>
          <td>(</td>
          <td class="paramname"></td><td>)</td>
          <td></td>
        </tr>
      </table>
</div><div class="memdoc">
<p>This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts. </p>

</div>
</div>
<a id="a51e4c416b3ace4840774cceaedcc4b9a"></a>
<h2 class="memtitle"><span class="permalink"><a href="#a51e4c416b3ace4840774cceaedcc4b9a">&#9670;&nbsp;</a></span>operator ushort()</h2>

<div class="memitem">
<div class="memproto">
      <table class="memname">
        <tr>
          <td class="memname">cv::RNG::operator <a class="el" href="../../d1/d1b/group__core__hal__interface.html#gab95f123a6c9bcfee6a343170ef8c5f69">ushort</a> </td>
          <td>(</td>
          <td class="paramname"></td><td>)</td>
          <td></td>
        </tr>
      </table>
</div><div class="memdoc">
<p>This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts. </p>

</div>
</div>
<a id="a16ca31c8e2ec0990df323b442ab09e4f"></a>
<h2 class="memtitle"><span class="permalink"><a href="#a16ca31c8e2ec0990df323b442ab09e4f">&#9670;&nbsp;</a></span>operator()() <span class="overload">[1/2]</span></h2>

<div class="memitem">
<div class="memproto">
      <table class="memname">
        <tr>
          <td class="memname">unsigned cv::RNG::operator() </td>
          <td>(</td>
          <td class="paramname"></td><td>)</td>
          <td></td>
        </tr>
      </table>
</div><div class="memdoc">

<p>returns a random integer sampled uniformly from [0, N). </p>
<p>The methods transform the state using the MWC algorithm and return the next random number. The first form is equivalent to <a class="el" href="../../d1/dd6/classcv_1_1RNG.html#ad8d035897a5e31e7fc3e1e6c378c32f5">RNG::next</a> . The second form returns the random number modulo N , which means that the result is in the range [0, N) . </p>

</div>
</div>
<a id="ac0112dc300696b1fc7998d37f15dd733"></a>
<h2 class="memtitle"><span class="permalink"><a href="#ac0112dc300696b1fc7998d37f15dd733">&#9670;&nbsp;</a></span>operator()() <span class="overload">[2/2]</span></h2>

<div class="memitem">
<div class="memproto">
      <table class="memname">
        <tr>
          <td class="memname">unsigned cv::RNG::operator() </td>
          <td>(</td>
          <td class="paramtype">unsigned&#160;</td>
          <td class="paramname"><em>N</em></td><td>)</td>
          <td></td>
        </tr>
      </table>
</div><div class="memdoc">
<p>This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts. </p><dl class="params"><dt>Parameters</dt><dd>
  <table class="params">
    <tr><td class="paramname">N</td><td>upper non-inclusive boundary of the returned random number. </td></tr>
  </table>
  </dd>
</dl>

</div>
</div>
<a id="a6c4889ee703a2b667df1fa298ffa312f"></a>
<h2 class="memtitle"><span class="permalink"><a href="#a6c4889ee703a2b667df1fa298ffa312f">&#9670;&nbsp;</a></span>operator==()</h2>

<div class="memitem">
<div class="memproto">
      <table class="memname">
        <tr>
          <td class="memname">bool cv::RNG::operator== </td>
          <td>(</td>
          <td class="paramtype">const <a class="el" href="../../d1/dd6/classcv_1_1RNG.html">RNG</a> &amp;&#160;</td>
          <td class="paramname"><em>other</em></td><td>)</td>
          <td> const</td>
        </tr>
      </table>
</div><div class="memdoc">

</div>
</div>
<a id="acde197860cea91e5aa896be8719457ae"></a>
<h2 class="memtitle"><span class="permalink"><a href="#acde197860cea91e5aa896be8719457ae">&#9670;&nbsp;</a></span>uniform() <span class="overload">[1/3]</span></h2>

<div class="memitem">
<div class="memproto">
      <table class="memname">
        <tr>
          <td class="memname">int cv::RNG::uniform </td>
          <td>(</td>
          <td class="paramtype">int&#160;</td>
          <td class="paramname"><em>a</em>, </td>
        </tr>
        <tr>
          <td class="paramkey"></td>
          <td></td>
          <td class="paramtype">int&#160;</td>
          <td class="paramname"><em>b</em>&#160;</td>
        </tr>
        <tr>
          <td></td>
          <td>)</td>
          <td></td><td></td>
        </tr>
      </table>
</div><div class="memdoc">

<p>returns uniformly distributed integer random number from [a,b) range </p>
<p>The methods transform the state using the MWC algorithm and return the next uniformly-distributed random number of the specified type, deduced from the input parameter type, from the range [a, b) . There is a nuance illustrated by the following sample:</p>
<div class="fragment"><div class="line"><a class="code" href="../../d1/dd6/classcv_1_1RNG.html#a06c28035e383bc9eff22e1fad619ddf6">RNG</a> rng;</div><div class="line"></div><div class="line"><span class="comment">// always produces 0</span></div><div class="line"><span class="keywordtype">double</span> a = rng.uniform(0, 1);</div><div class="line"></div><div class="line"><span class="comment">// produces double from [0, 1)</span></div><div class="line"><span class="keywordtype">double</span> a1 = rng.uniform((<span class="keywordtype">double</span>)0, (<span class="keywordtype">double</span>)1);</div><div class="line"></div><div class="line"><span class="comment">// produces float from [0, 1)</span></div><div class="line"><span class="keywordtype">float</span> b = rng.uniform(0.f, 1.f);</div><div class="line"></div><div class="line"><span class="comment">// produces double from [0, 1)</span></div><div class="line"><span class="keywordtype">double</span> c = rng.uniform(0., 1.);</div><div class="line"></div><div class="line"><span class="comment">// may cause compiler error because of ambiguity:</span></div><div class="line"><span class="comment">//  RNG::uniform(0, (int)0.999999)? or RNG::uniform((double)0, 0.99999)?</span></div><div class="line"><span class="keywordtype">double</span> d = rng.uniform(0, 0.999999);</div></div><!-- fragment --><p>The compiler does not take into account the type of the variable to which you assign the result of <a class="el" href="../../d1/dd6/classcv_1_1RNG.html#acde197860cea91e5aa896be8719457ae" title="returns uniformly distributed integer random number from [a,b) range ">RNG::uniform</a> . The only thing that matters to the compiler is the type of a and b parameters. So, if you want a floating-point random number, but the range boundaries are integer numbers, either put dots in the end, if they are constants, or use explicit type cast operators, as in the a1 initialization above. </p><dl class="params"><dt>Parameters</dt><dd>
  <table class="params">
    <tr><td class="paramname">a</td><td>lower inclusive boundary of the returned random number. </td></tr>
    <tr><td class="paramname">b</td><td>upper non-inclusive boundary of the returned random number. </td></tr>
  </table>
  </dd>
</dl>
<dl><dt><b>Examples: </b></dt><dd><a class="el" href="../../d5/d04/samples_2cpp_2convexhull_8cpp-example.html#a8">samples/cpp/convexhull.cpp</a>, <a class="el" href="../../d2/dcf/samples_2cpp_2falsecolor_8cpp-example.html#a16">samples/cpp/falsecolor.cpp</a>, <a class="el" href="../../d9/dde/samples_2cpp_2kmeans_8cpp-example.html#a5">samples/cpp/kmeans.cpp</a>, <a class="el" href="../../df/dee/samples_2cpp_2minarea_8cpp-example.html#a5">samples/cpp/minarea.cpp</a>, <a class="el" href="../../de/d06/samples_2cpp_2tutorial_code_2ImgProc_2basic_drawing_2Drawing_2_8cpp-example.html#a10">samples/cpp/tutorial_code/ImgProc/basic_drawing/Drawing_2.cpp</a>, and <a class="el" href="../../d4/d40/samples_2cpp_2watershed_8cpp-example.html#a33">samples/cpp/watershed.cpp</a>.</dd>
</dl>
</div>
</div>
<a id="a47acb9cf49f56ae6b86ab08c51f0f7d3"></a>
<h2 class="memtitle"><span class="permalink"><a href="#a47acb9cf49f56ae6b86ab08c51f0f7d3">&#9670;&nbsp;</a></span>uniform() <span class="overload">[2/3]</span></h2>

<div class="memitem">
<div class="memproto">
      <table class="memname">
        <tr>
          <td class="memname">float cv::RNG::uniform </td>
          <td>(</td>
          <td class="paramtype">float&#160;</td>
          <td class="paramname"><em>a</em>, </td>
        </tr>
        <tr>
          <td class="paramkey"></td>
          <td></td>
          <td class="paramtype">float&#160;</td>
          <td class="paramname"><em>b</em>&#160;</td>
        </tr>
        <tr>
          <td></td>
          <td>)</td>
          <td></td><td></td>
        </tr>
      </table>
</div><div class="memdoc">
<p>This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts. </p>

</div>
</div>
<a id="a8325cc562269b47bcac2343639b6fafc"></a>
<h2 class="memtitle"><span class="permalink"><a href="#a8325cc562269b47bcac2343639b6fafc">&#9670;&nbsp;</a></span>uniform() <span class="overload">[3/3]</span></h2>

<div class="memitem">
<div class="memproto">
      <table class="memname">
        <tr>
          <td class="memname">double cv::RNG::uniform </td>
          <td>(</td>
          <td class="paramtype">double&#160;</td>
          <td class="paramname"><em>a</em>, </td>
        </tr>
        <tr>
          <td class="paramkey"></td>
          <td></td>
          <td class="paramtype">double&#160;</td>
          <td class="paramname"><em>b</em>&#160;</td>
        </tr>
        <tr>
          <td></td>
          <td>)</td>
          <td></td><td></td>
        </tr>
      </table>
</div><div class="memdoc">
<p>This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts. </p>

</div>
</div>
<h2 class="groupheader">Member Data Documentation</h2>
<a id="a993bd2e6a5a9b8f3b37ba6049b523136"></a>
<h2 class="memtitle"><span class="permalink"><a href="#a993bd2e6a5a9b8f3b37ba6049b523136">&#9670;&nbsp;</a></span>state</h2>

<div class="memitem">
<div class="memproto">
      <table class="memname">
        <tr>
          <td class="memname"><a class="el" href="../../d1/d1b/group__core__hal__interface.html#gabc0f5bc07737e498f287334775dff2b6">uint64</a> cv::RNG::state</td>
        </tr>
      </table>
</div><div class="memdoc">

</div>
</div>
<hr/>The documentation for this class was generated from the following file:<ul>
<li>opencv2/<a class="el" href="../../d0/d9c/core_2include_2opencv2_2core_8hpp.html">core.hpp</a></li>
</ul>
</div><!-- contents -->
<!-- HTML footer for doxygen 1.8.6-->
<!-- start footer part -->
<hr class="footer"/><address class="footer"><small>
Generated on Fri Apr 2 2021 11:36:43 for OpenCV by &#160;<a href="http://www.doxygen.org/index.html">
<img class="footer" src="../../doxygen.png" alt="doxygen"/>
</a> 1.8.13
</small></address>
<script type="text/javascript">
//<![CDATA[
addTutorialsButtons();
//]]>
</script>
</body>
</html>
